<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 
    <h:head></h:head> 
    <body> 
        <p:layout fullPage="true">  
  
         <p:layoutUnit position="north" size="120" style =" text-align : center;"  > 
    		<style type="text/css">
        	.ui-widget{font-size:90% !important;}  
      		</style> 
      			<a href="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeehome.xhtml">
         <p:graphicImage  value="logo.jpg" style=" height:100px;" />
         </a>
		</p:layoutUnit> 
		 
      <p:layoutUnit position="south" size="50"  resizable="false" closable="false" collapsible="false">  
         <h:form style =" text-align : center;">
           <p:button outcome="/employee/employeePersonal.xhtml" value="Ok, fatto"  icon="ui-icon-arrowrefresh-1-w" ></p:button>
         </h:form>  
        </p:layoutUnit>  
      
        <p:layoutUnit position="west" size="200" header="Pagine utili" resizable="false" closable="false" collapsible="false">   
            <p:menu>  
               
                      <p:menuitem value="Pacchetti" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/packageManagement.xhtml" />  
                     <p:menuitem value="Pagina personale" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeePersonal.xhtml" />  
           
            </p:menu>   
                       
        </p:layoutUnit>  
       
      
      <p:layoutUnit position="center">  
	  <h:form id="form">
 <p:dataTable var="hotel" value="#{hotelManagement.hotelModel}" rowKey="#{hotel.idProduct}" paginator="true" rows="10"  
                selection="#{hotelManagement.selectedHotel}" selectionMode="single" 
                filteredValue="#{hotelManagement.filteredHotels}" id="hoteltable"
                 rowsPerPageTemplate="10,15,50" >  
   
  
                <f:facet name="header">
                    Alberghi
                </f:facet>  
                
                    <p:column  headerText="Nome" sortBy="#{hotel.name}" filterBy="#{hotel.name}" id="name">
                    
                    <p:commandLink value="#{hotel.name}" update=":modForm:display" oncomplete="modDialog.show()"  title="View">
                        <f:setPropertyActionListener value="#{hotel}" target="#{hotelManagement.selectedHotel}" />    
                    </p:commandLink>
                    
                	</p:column>
                	
                    <p:column  headerText="Creatore" sortBy="#{hotel.employeeCreator}" filterBy="#{hotel.employeeCreator}" id="employeeCreator">
                      #{hotel.employeeCreator}  
                      </p:column> 
                      <p:column  headerText="Area" sortBy="#{hotel.area}" filterBy="#{hotel.area}" id="area">
                      #{hotel.area}  
                      </p:column> 
                       <p:column  headerText="Luogo" sortBy="#{hotel.place}" filterBy="#{hotel.place}" id="place">  
                      #{hotel.place}  
                      </p:column> 
                       <p:column  headerText="Data Inizio" sortBy="#{hotel.timeStart}" filterBy="#{hotel.timeStart}" id="timeStart">  
                      #{hotel.timeStart}  
                      </p:column> 
                       <p:column  headerText="Data Fine" sortBy="#{hotel.timeEnd}" filterBy="#{hotel.timeEnd}" id="timeEnd">  
                      #{hotel.timeEnd}  
                      </p:column> 
                        <p:column  headerText="Tipo camera" sortBy="#{hotel.room_type}" filterBy="#{hotel.room_type}" id="room_type">  
                      #{hotel.room_type}  
                      </p:column> 
                       <p:column  headerText="Informazioni" sortBy="#{hotel.more_info}" filterBy="#{hotel.more_info}" id="more_info">  
                      #{hotel.more_info}  
                      </p:column> 
                     <p:column  headerText="Costo" sortBy="#{hotel.cost}" filterBy="#{hotel.cost}" id="cost">  
                      #{hotel.cost}  
                      </p:column> 
                      <p:column  headerText="Stato" sortBy="#{hotel.state}" filterBy="#{hotel.state}" id="state">  
                      #{hotel.state}  
                      </p:column> 
                      
                       

               
               <f:facet name="footer">
                    <p:commandButton  value="Aggiungi nuovo" onclick="PF('dlg3').show();" type="button" icon="ui-icon-star"/> 
                    
                    <p:commandButton value="Elimina" actionListener="#{hotelManagement.deleteHotel}" oncomplete="PF('delMess').show();" update="hoteltable" icon="ui-icon-trash"/>
                    
                          
                </f:facet>          
              </p:dataTable>
                
         </h:form>   
         
   
    
    
        </p:layoutUnit>  
         <p:dialog header="Eliminazione" widgetVar="delMess" showEffect="explode" hideEffect="bounce" resizable="false"
                   width="200" height="100" dynamic="true">      
             #{hotelManagement.messageDelete}
         </p:dialog>
         
        <p:dialog header="Modifica" widgetVar="modMess" showEffect="explode" hideEffect="bounce" resizable="false"
                   width="200" height="100" dynamic="true">      
            #{hotelManagement.messageModify}
         </p:dialog>
      
        </p:layout> 
         
          <p:dialog header="Inserisci i dati del nuovo albergo" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" resizable="false">  
     <h:form>
     <h:panelGrid columns="2" cellpadding="5">  
     
           <h:outputLabel for="newname" value="Nome:" />  
            <p:inputText value="#{hotelManagement.name}" id="newname" required="true" label="newname" /> 
                     
            <h:outputLabel for="newarea" value="Area:" />  
            <p:inputText value="#{hotelManagement.area}" id="newarea" required="true" label="newarea" />
            
            <h:outputLabel for="newplace" value="Luogo:" />  
            <p:inputText value="#{hotelManagement.place}" id="newplace" required="true" label="newplace" />  
            
            <h:outputLabel for="newtimeStart" value="Data inizio:" />  
        
            <p:calendar id="newtimeStart" value="#{hotelManagement.timeStart}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy" showOn="button" readonlyInput="true" label="newtimeStart"/>
            
            <h:outputLabel for="newtimeEnd" value="Data fine:" />  
             <p:calendar id="newtimeEnd" value="#{hotelManagement.timeEnd}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy" showOn="button" readonlyInput="true" label="newtimeEnd"/>
            
            <h:outputLabel for="newroom_type" value="Tipo camera:" />  
            <p:inputText value="#{hotelManagement.room_type}" id="newroom_type" required="true" label="newroom_type" />
            
            <h:outputLabel for="newmore_info" value="Informazioni:" />  
            <p:inputText value="#{hotelManagement.more_info}" id="newmore_info" required="true" label="newmore_info" />
            
            <h:outputLabel for="newcost" value="Costo:" />  
            <p:inputText value="#{hotelManagement.cost}" id="newcost" required="true" label="newcost" />
            
            <f:facet name="footer">  
                <p:commandButton id="createButton" value="Crea" update=":form:hoteltable"   
                    actionListener="#{hotelManagement.newHotel}"  
                   oncomplete="dlg3.hide();"/>  
                
               
            </f:facet>  
        </h:panelGrid>  
        </h:form>
        
        
        	</p:dialog> 
        	
        <script type="text/javascript">  
    function handleLoginRequest(xhr, status, args) {  
        if( !args.loggedIn) {  
            PF('dlg3').jq.effect("shake", { times:5 }, 100);  
        }   
        else {  
            PF('dlg3').hide();  
            $('#loginLink').fadeOut();  
        }  
    }  
</script>  	
    
       <p:dialog header="Modifica i dati dell'albergo" widgetVar="modDialog" resizable="false" id="modDlg" > 
               <h:form id="modForm">
               <p:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
                  
			<h:outputText value="Nome:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.name}" />
            <h:outputText value="Nuovo nome:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.name}"/>			
						
			<h:outputText value="Area:"></h:outputText>			
						<h:outputText value="#{hotelManagement.selectedHotel.area}" />
			<h:outputText value="Nuova area:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.area}"/>
						
            <h:outputText value="Luogo:"></h:outputText>
						<h:outputText value="#{hotelManagement.selectedHotel.place}" />
			<h:outputText value="Nuovo luogo:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.place}"/>
						
		    <h:outputText value="Data inizio:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.timeStart}" />
            <h:outputText value="Nuova data inizio:"></h:outputText>
						<p:calendar id="modtimeStart" value="#{hotelManagement.selectedHotel.timeStart}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy" showOn="button" readonlyInput="true" label="modtimeStart"/>
						
			<h:outputText value="Data fine:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.timeEnd}" />
            <h:outputText value="Nuova data fine:"></h:outputText>
						<p:calendar id="modtimeEnd" value="#{hotelManagement.selectedHotel.timeEnd}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy" showOn="button" readonlyInput="true" label="modtimeEnd"/>
						
			<h:outputText value="Tipo camera:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.room_type}" />
            <h:outputText value="Nuovo tipo camera:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.room_type}"/>
						
			<h:outputText value="Informazioni:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.more_info}" />
            <h:outputText value="Nuove informazioni:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.more_info}"/>
						
			<h:outputText value="Costo:"></h:outputText>
                        <h:outputText value="#{hotelManagement.selectedHotel.cost}" />
            <h:outputText value="Nuovo costo:"></h:outputText>
						<h:inputText value="#{hotelManagement.selectedHotel.cost}"/>
						
      		<f:facet name="footer">
                     
                            <p:commandButton value="Salva modifiche" update=":form:hoteltable"  
                            oncomplete="modDialog.hide(); PF('modMess').show();" actionListener="#{hotelManagement.updateHotel}"/>
                    </f:facet>
			
                </p:panelGrid> 
             </h:form>
          </p:dialog> 
                         
             
         
      
<p:growl id="growl" showDetail="true" life="5000" />
         
<script type="text/javascript">  
    function handleSubmitRequest(xhr, status, args, dialogName, formName) {  
            dialog = jQuery('#'+dialogName);
        if(args.validationFailed) {  
            dialog.effect("shake", { times:3 }, 100);  
        } else {
            clearForm(formName);
            newUserDialog.hide(); 
            userDialog.hide(); 
        }  
    }
    function clearForm(formName){
        jQuery('#'+formName).each(function(){
	        this.reset();
	});
    }
</script> 
 
        
    </body> 
    
    
</html>